var ueditor;
define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'polite.polite_play/index',
        add_url: 'polite.polite_play/add',
        edit_url: 'polite.polite_play/edit',
        delete_url: 'polite.polite_play/delete',
        modify_url: 'polite.polite_play/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,skin:'all',
                toolbar: ['refresh',
                    [{
                        text: '添加',
                        url: init.add_url,
                        method: 'open',
                        auth: 'add',
                        class: 'layui-btn layui-btn-normal layui-btn-sm',
                        icon: 'fa fa-plus ',
                        extend: 'data-full="true"',
                    }],
                    'delete'],
                cols: [[
                    {type: "checkbox"},
                    {field: 'id', width: 80, title: 'ID'},
                    {field: 'name', minWidth: 80, title: '名称',edit:'text'},
                    {field: 'type_text', minWidth: 80, title: '分类',search: false,edit:'text'},
                    {field: 'contact_phone', width: 120, title: '联系电话',search: false,edit:'text'},
                    {field: 'order', width: 80, title: '排序',search: false,edit:'number'},
                    {field: 'is_recommend', width: 120, title: '本期推荐',selectList: {0:'否',1:'是'}, templet: function(d){let color='';if(d.is_recommend_text=='是'){color='green';}return '<span style="color:'+ color+'">'+d.is_recommend_text+'</span>';}},
                    {field: 'status', title: '状态', width: 85, search: 'select', selectList: {0:'隐藏',1:'显示'}, templet: ea.table.switch},
                    {field: 'create_time', width: 180, title: '创建时间', search: 'range'},
                    {
                        width: 180,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '编辑',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-success',
                                extend: 'data-full="true"',
                            }],'delete']
                    }
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen(function (e){
                e.content= ueditor.getContent();
                return e;
            });
        },
        edit: function () {
            ea.listen(function (e){
                e.content= ueditor.getContent();
                return e;
            });
        },
    };
    return Controller;
});